<template>
	<div>
		<div style="margin-top: 200px;">
			<van-field :value="ownertel" center clearable label="电话号" placeholder="系统中预留的电话号" :use-button-slot="true"
				:border="false" @input="change1">
				<van-button slot="button" size="small" type="info" custom-class="button" @click="send">验证并绑定
				</van-button>
			</van-field>
		</div>

	</div>
</template>

<script>
	export default {
		data() {
			return {
				ownertel: '',
			}
		},
		methods: {
			change1(event) {
				this.ownertel = event.detail;
			},
			send() {
				uni.request({
					method: 'POST',
					url: 'https://www.gjegm.ltd/czsczq/userinfo/bandOPenidByTle',
					data: {
						openid: uni.getStorageSync('openid'),
						tel: this.ownertel
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: (res) => {
						if (res.data.obj){
							uni.setStorageSync('userid', res.data.obj2);
							uni.reLaunch({
								url: '/pages/menu/index'
							});
							uni.showToast({
								title: '绑定成功!',
								mask: true,
								icon: 'none'
							})
						}else {
							uni.showToast({
								title: '手机号未在系统中录入!',
								mask: true,
								icon: 'none'
							})
						}
					}
				})
			}
		}
	}
</script>

<style>
</style>
